package cn.mumzone.pos.api.service;

import java.util.HashMap;
import java.util.List;

import cn.mumzone.basic.net.response.BaseResponse;
import cn.mumzone.basic.net.response.PageListResponse;
import cn.mumzone.pos.model.CardReturnEntity;
import cn.mumzone.pos.model.DepositGoodsEntity;
import cn.mumzone.pos.model.DepositGoodsRecordEntity;
import cn.mumzone.pos.model.IntegralRecordEntity;
import cn.mumzone.pos.model.LevelListEntity;
import cn.mumzone.pos.model.MemberAccountEntity;
import cn.mumzone.pos.model.MemberEntity;
import cn.mumzone.pos.model.MemberTicketEntity;
import cn.mumzone.pos.model.ReturnEntity;
import cn.mumzone.pos.model.SalesTimesCard;
import cn.mumzone.pos.model.TimeCardEntity;
import cn.mumzone.pos.model.TransactionRecordEntity;
import okhttp3.RequestBody;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by qiuzhenhuan on 2019/6/28.
 */

public interface MemberService {

    /**
     * 新增/修改 会员
     *
     * @param body
     * @return
     */
    @FormUrlEncoded
    @POST("egg_member/api/v1/pos/member/newMember")
    Observable<Response<BaseResponse<MemberEntity>>> createNewMember(@FieldMap HashMap<String, String> body);


    /**
     * 查询会员基础信息
     *
     * @param phone
     * @return
     */
    @GET("egg_member/api/v1/pos/endBill/selectMemberInfo")
    Observable<Response<BaseResponse<MemberEntity>>> getMemberInfoByPhone(@Query("phone") String phone);

    /**
     * 会员详情接口
     *
     * @param phone
     * @return
     */
    @GET("egg_member/api/v1.7/pos/member/memberDetail")
    Observable<Response<BaseResponse<MemberEntity>>> getMemberDetailByPhone(@Query("phone") String phone);


    /**
     * 获取会员优惠券&体验券
     *
     * @param memberId
     * @param viewType 1 劵 2次卡
     * @param page
     * @param pageSize
     * @return
     */
    @GET("egg_member/api/v1/pos/member/getTicketCardAllListPageVersion")
    Observable<Response<BaseResponse<MemberTicketEntity>>> getTicketAllListPage(
            @Query("memberId") String memberId, @Query("viewType") String viewType,
            @Query("pageNum") String page, @Query("pageSize") String pageSize);


    /**
     * 获取会员优惠券&体验券&次卡
     *
     * @param memberId
     * @param viewType 1劵 2次卡
     * @param page
     * @param pageSize
     * @return
     */
    @GET("egg_member/api/v1/pos/member/getTicketCardAllListPageVersion")
    Observable<Response<BaseResponse<PageListResponse<TimeCardEntity>>>> getTimesCardAllListPage(
            @Query("memberId") String memberId, @Query("viewType") String viewType,
            @Query("pageNum") String page, @Query("pageSize") String pageSize);

    /**
     * 添加宝宝
     *
     * @param body
     * @return
     */
    @POST("egg_member/api/v1/pos/member/newBaby")
    Observable<Response<BaseResponse<MemberEntity.BabysBean>>> createNewBaby(@Body RequestBody body);


    /**
     * 次卡详情
     *
     * @param id
     * @return
     */
    @GET("egg_member/api/v1.3/pos/timesCard/timesCardUsedDetail")
    Observable<Response<BaseResponse<TimeCardEntity>>> getTimeCardDetail(@Query("id") String id);


    /**
     * 获取退卡信息
     *
     * @param requestMap
     * @return
     */
    @FormUrlEncoded
    @POST("egg_goods/api/v1.3/pos/returnedGoods/calculateCardAmountForReturn")
    Observable<Response<BaseResponse<CardReturnEntity>>> getReturnCardDetail(@FieldMap HashMap<String, String> requestMap);


    /**
     * 确认退卡
     *
     * @param requestMap
     * @return
     */
    @FormUrlEncoded
    @POST("egg_goods/api/v1.3/pos/returnedGoods/confirmCardForReturn")
    Observable<Response<BaseResponse<List<ReturnEntity>>>> returnCard(@FieldMap HashMap<String, String> requestMap);


    /**
     * 会员寄存商品信息
     *
     * @param memberCompanyId
     * @return
     */
    @GET("egg_order/api/v1/pos/member/consignedGoods")
    Observable<Response<BaseResponse<List<DepositGoodsEntity>>>> consignedGoods(@Query("memberCompanyId") String memberCompanyId);


    /**
     * 会员寄存商品领取记录
     *
     * @param orderCode
     * @param subCode
     * @param goodsId
     * @return
     */
    @GET("egg_order/api/v1/pos/member/consignedGoodsReceiveRecord")
    Observable<Response<BaseResponse<List<DepositGoodsRecordEntity>>>> consignedGoodsReceiveRecord(@Query("orderCode") String orderCode,
                                                                                                   @Query("subCode") String subCode,
                                                                                                   @Query("goodsId") String goodsId);

    /**
     * 领取寄存商品
     *
     * @param body
     * @return
     */
    @POST("egg_order/api/v1/pos/member/receiveConsignedGoods")
    Observable<Response<BaseResponse<String>>> receiveConsignedGoods(@Body RequestBody body);


    /**
     * 售卡
     *
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GET("egg_goods/api/v1/pos/timesCard/getByTimesCardListPage")
    Observable<Response<BaseResponse<PageListResponse<SalesTimesCard>>>> getSaleTimeCardList(
            @Query("pageNum") String pageNum, @Query("pageSize") String pageSize);

    /**
     * 查询会员等级
     *
     * @return
     */
    @GET("egg_member/api/v1.7/member/getMemberLevelList")
    Observable<Response<BaseResponse<List<LevelListEntity>>>> getMemberLevel(@Query("orgId") String orgId);


    /**
     * 查询会员积分交易记录
     *
     * @return
     */
    @POST("egg_member/api/v1/member/integralList")
    Observable<Response<BaseResponse<PageListResponse<IntegralRecordEntity>>>> selectIntegralRecord(@Body RequestBody body);


    /**
     * 查询会员交易记录
     * @param type
     * @param memberId
     * @param dateTime
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GET("egg_order/api/v2.1/pos/service/selectTransactionRecord")
    Observable<Response<BaseResponse<PageListResponse<TransactionRecordEntity>>>> selectTransactionRecord(
            @Query("type") String type,
            @Query("memberCompanyId") String memberId, @Query("dateTime") String dateTime,
            @Query("pageNum") String pageNum, @Query("pageSize") String pageSize);


    /**
     * 会员账户信息
     * @param memberId
     * @return
     */
    @FormUrlEncoded
    @POST("egg_goods/api/v2/pos/endBill/getMemberStoreList")
    Observable<Response<BaseResponse<MemberAccountEntity>>> getMemberStoreList(@Field("memberCompanyId") String memberId);


}